package com.bgc.codegenerate.utils;

import com.bgc.codegenerate.CodeGenerate;

import java.io.IOException;

/**
 * 解析配置文件
 */
public class ConfigurationParser {

    /**
     * 配置文件解析
     *
     * @param inputFile 配置文件
     * @param overwrite 是否重写参数
     * @return
     * @throws IOException
     */

    public static GenerateConfiguration parseConfiguration(String tableName) throws IOException {
        GenerateConfiguration config = new GenerateConfiguration();
        config.setProjectPath("generate/src/main/java");
        config.setJavaModelPackage(CodeGenerate.BASE_PACKAGE);
        config.setTableName(tableName);
        String entityName = new Converter().convertToJava(tableName);
        config.setOrgDomainObjectName(entityName);
        entityName = entityName.substring(0, 1).toUpperCase() + entityName.substring(1);
        config.setDomainObjectName(entityName);
        config.setOverwrite(true);
        return config;
    }
}
